<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/pages/common/meta.jspf"%>
<link rel="stylesheet" type="text/css" href="${basePath}/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="${basePath}/css/style.min.css" />
<link rel="stylesheet" type="text/css" href="${basePath}/css/login.css" />
<body class="signin">
<input type="hidden" id="callbackUrl" value="${callbackUrl}">
<div class="signinpanel">
    <div class="row">
        <div class="col-sm-7">
            
        </div>
        <div class="col-sm-5">
            <form>
                <h4 class="no-margins"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">登录：</font></font></h4>
                <p class="m-t-md"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;" id="errorMsg"></font></font></p>
                <input type="text" class="form-control uname" id="username" name="username" placeholder="用户名">
                <input type="password" class="form-control pword m-b" id="password" name="password" placeholder="密码">
                <a href=""><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"></font></font></a>
                <button type="button" id="loginBtn" class="btn btn-success btn-block"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">登录</font></font></button>
            </form>
        </div>
    </div>
    <div class="signup-footer">
        <div class="pull-left"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
            ©2015版权所有。</font><font style="vertical-align: inherit;">董光文
        </font></font></div>
    </div>
</div>
<div class="goog-te-spinner-pos"><div class="goog-te-spinner-animation"><svg xmlns="http://www.w3.org/2000/svg" class="goog-te-spinner" width="96px" height="96px" viewBox="0 0 66 66"><circle class="goog-te-spinner-path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle></svg></div></div>
</body>

<!-- 引入footer文件 -->
<%@include file="/WEB-INF/pages/common/footer.jspf"%>

<script type="text/javascript">
function login(username,password,callBackUrl){
	$.ajax({
		url:"${basePath}/login",
		type:"post",
		data:{
			username:username,
			password:password
		},
		success:function(result){
			if(result.code==200){
				if(callBackUrl){
					//请求成功，回调地址不为空，则请求回调地址
					window.location.href=callBackUrl;
				}else if(!callBackUrl && result.data!=null){
					window.location.href=result.data;
				}
				
			}
		},
		error:function(e){
			console.log(JSON.stringify(e));
		}
	});
}
function validate(username,password){
	if(!username){
		$("#errorMsg").text("用户名不能为空");
		return false;
	}
	if(!password){
		$("#errorMsg").text("密码不能为空");
		return false;
	}
	return true;
}
$(function(){
	$("#loginBtn").click(function(){
		var username=$("#username").val();
		var password=$("#password").val();
		if(!validate(username,password)){
			return;
		}
		var callbackUrl=$("#callbackUrl").val();
		login(username,password,callbackUrl);
	});
});
</script>
</html>